package com.sharding.shardingdemo.service.impl;


import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sharding.shardingdemo.dao.UserMsgDao;
import com.sharding.shardingdemo.entity.UserMsg;
import com.sharding.shardingdemo.service.UserMsgService;
import com.sharding.shardingdemo.utils.PageUtils;
import com.sharding.shardingdemo.utils.Query;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 
 *
 * @author zjmm zjmm@gmail.com
 * @since 1.0.0 2022-08-16
 */
@Service
public class UserMsgServiceImpl extends ServiceImpl<UserMsgDao, UserMsg> implements UserMsgService {


    @Override
    public PageUtils queryPage(Map<String, Object> map) {

        String status= (String) map.get("status");
        IPage<UserMsg> page = this.page(
                new Query<UserMsg>().getPage(map),
                new QueryWrapper<UserMsg>()
                        .eq(StringUtils.isNotBlank(status),"status", Convert.toInt(status))
        );
        return new PageUtils(page);
    }
}